﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace SharpSoft.WPF.Controls
{
    public class ExpanderMenuTemplateSelector: DataTemplateSelector
    {
        public DataTemplate Level0 { get; set; }
        public DataTemplate Level1 { get; set; }
        public DataTemplate OtherLevel { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        { 
               var level = ExpanderMenu.GetLevel(item as MenuItem);
            if (level==0)
            {
                return Level0;
            }
            else if(level==1)
            {
                return Level1;
            }
            else
            {
                if (OtherLevel!=null)
                {
                    return OtherLevel;
                }
            }
            return base.SelectTemplate(item, container);
        }
    }
}
